import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:magic_car/baoxiu/guarantee.dart';
import 'package:magic_car/bussiness/bussinessEditResult.dart';
import 'package:magic_car/bussiness/bussinessinspect.dart';
import 'package:magic_car/jiance/editresult.dart';
import 'package:magic_car/jiance/inspectresults.dart';
import 'package:magic_car/jiance/jiance_detail.dart';
import 'package:magic_car/jiance/start.dart';
import 'package:magic_car/res/colors.dart';
import 'package:magic_car/util/HttpHelper.dart';
import 'package:magic_car/util/config.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:magic_car/jiance/papularInspects.dart';
import 'package:toast/toast.dart';

class BOrderRecPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new ActState();
  }
}

class ActState extends State<BOrderRecPage>
    with SingleTickerProviderStateMixin {
  List<Choice> _tabs = [];
  TabController mTabController;
  int mCurrentPosition = 0;
  List orders = [];
  int type = 1;
  String status = "1";
  String keyword = "";
  int page = 1;
  bool hasmore = true;
  ScrollController scrollController = new ScrollController();
  TextEditingController keywordcontroller = new TextEditingController();
  @override
  @override
  Widget build(BuildContext context) {
    if (status == "1") {
      return new Scaffold(
        appBar: new AppBar(
          titleSpacing: 0,
          title: new Text(
            '检测记录',
            style: TextStyle(fontSize: Config.title_size),
          ),
          backgroundColor: Colors.white,
          elevation: 0,
          bottom: new TabBar(
            indicatorSize: TabBarIndicatorSize.label,
            indicatorColor: Color.fromRGBO(255, 204, 48, 1),
            labelColor: Color.fromRGBO(255, 204, 48, 1),
            unselectedLabelColor: Colors.black45,
            tabs: _tabs.map((Choice choice) {
              return new Tab(
                text: choice.title,
              );
            }).toList(),
            controller: mTabController,
          ),
        ),

        // body: NestedScrollView(
        //   headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
        //     return [
        //       new SliverAppBar(
        //         pinned: true,
        //         expandedHeight: 0.0,
        //         title: Text('订单'),
        //         backgroundColor: Colors.white,
        //          bottom:  new TabBar(
        //                 indicatorSize: TabBarIndicatorSize.label,
        //                 indicatorColor: Color.fromRGBO(27, 182, 251, 1),
        //                 labelColor: Color.fromRGBO(27, 182, 251, 1),
        //                 unselectedLabelColor: Colors.black45,
        //                 tabs: _tabs.map((Choice choice) {
        //                   return new Tab(
        //                     text: choice.title,
        //                     icon: new Icon(
        //                       choice.icon,
        //                     ),
        //                   );
        //                 }).toList(),
        //                 controller: mTabController,

        //             ),
        //            // preferredSize: new Size(double.infinity, 64.0),
        //         // bottom: PreferredSize(
        //         //     child: new Container(
        //         //       color: Colors.white,
        //         //       child: new TabBar(
        //         //         indicatorSize: TabBarIndicatorSize.label,
        //         //         indicatorColor: Color.fromRGBO(27, 182, 251, 1),
        //         //         labelColor: Color.fromRGBO(27, 182, 251, 1),
        //         //         unselectedLabelColor: Colors.black45,
        //         //         tabs: _tabs.map((Choice choice) {
        //         //           return new Tab(
        //         //             text: choice.title,
        //         //             icon: new Icon(
        //         //               choice.icon,
        //         //             ),
        //         //           );
        //         //         }).toList(),
        //         //         controller: mTabController,
        //         //       ),
        //         //     ),
        //         //     preferredSize: new Size(double.infinity, 64.0)),
        //       )
        //     ];
        //   },
        body: 
        new TabBarView(
          children: _tabs.map((Choice choice) {
            return new Padding(
                padding: const EdgeInsets.all(0.0),
                child: new Center(
                    child: Container(
                        decoration: new BoxDecoration(
                          color: Colours.base_page_color,
                        ),
                        child: Stack(
                          children: <Widget>[
                            Align(
                              alignment: Alignment.topLeft,
                              child: SizedBox(
                                  width: double.infinity,
                                  height: 50,
                                  child: Padding(
                                      padding:
                                          new EdgeInsets.fromLTRB(15, 5, 15, 0),
                                      // padding: new EdgeInsets.all(10),
                                      child: Container(
                                          child: Row(
                                              mainAxisAlignment:
                                                  MainAxisAlignment.start,
                                              children: <Widget>[
                                            Expanded(
                                              child: new Container(
                                                child: new TextField(
                                                   controller: keywordcontroller,
                                                  onChanged: (value){
                                                    setState(() {
                                                      keyword = value;
                                                     // keywordcontroller.text = value;
                                                    });

                                                  },
                                                  onSubmitted: (value) {
                                                    FocusScope.of(context).requestFocus(FocusNode());
                                                    print(value);
                                                    //if(value=="")return;
                                                    setState(() {
                                                      keyword = value;
                                                      page = 1;
                                                      //keywordcontroller.text = keyword;
                                                      // end = false;
                                                    });
                                                    print('搜索');
                                                    loaddata();
                                                  },
                                                  // controller: _phonecontroller,
                                                  decoration:
                                                      new InputDecoration(
                                                          border:
                                                              InputBorder.none,
                                                          hintText: '车牌或车架号关键字',
                                                          prefixIcon: Icon(
                                                              Icons.search)),
                                                ),
                                                decoration: new BoxDecoration(
//背景
                                                  color: Colors.white,
                                                  //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                                                  borderRadius:
                                                      BorderRadius.all(
                                                          Radius.circular(
                                                              25.0)),
                                                  //设置四周边框
                                                  border: new Border.all(
                                                      width: 1,
                                                      color: Colors.white),
                                                ),
                                              ),
                                            ),
                                            Container(
                                              width: 20,
                                            ),
                                            InkWell(
                                              onTap: () {
                                                FocusScope.of(context).requestFocus(FocusNode());
                                                setState(() {
                                                  page = 1;
                                                  // end = false;
                                                });
                                                print('搜索');
                                                loaddata();
                                              },
                                              child: Text('搜索'),
                                            )
                                          ])))),
                            ),
                            Align(
                                alignment: Alignment.bottomCenter,
                                child: Padding(
                                  padding:
                                      new EdgeInsets.fromLTRB(0, 60, 0, 10),
                                  child: new Container(
                                      child: new ListView(
                                    controller: scrollController,
                                    children: <Widget>[buildcontent()],
                                  )),
                                  // child: new RefreshIndicator(
                                  //   onRefresh: _onRefresh,
                                  //   child: ListView.builder(
                                  //       itemCount: carlist.length,
                                  //       itemBuilder:
                                  //           (BuildContext context, int index) {
                                  //         return messageitem(carlist[index]);
                                  //       }),
                                  // )
                                )),
                          ],
                        )))
                //  new Container(
                //     child: new ListView(
                //   children: <Widget>[buildcontent()],
                // ))
                );
          }).toList(),
          controller: mTabController,
        ),
      );
    } else {
      return new Scaffold(
        appBar: new AppBar(
          title: new Text('订单'),
          backgroundColor: Colors.white,
          elevation: 0,
        ),
        body: new Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Text('您的账号正在审核，请耐心等待！')

              // userinfo["failreason"]!=""?
              // Padding(padding: new EdgeInsets.fromLTRB(0, 10, 0, 0),child:
              // FlatButton(onPressed: (){
              // Navigator.pushNamed(context, "exam");
              // }, child:
              // new Text(''),
              // color: Color.fromRGBO(27, 182, 251, 1),
              // ) ):new Text(''),
            ],
          ),
        ),
      );
    }
  }

  loaduserinfo() async {
    // LoadingPage loadpage = new LoadingPage(context);
    // loadpage.show();
    SharedPreferences pref = await SharedPreferences.getInstance();
    Map<String, String> map = new Map();
    map["id"] = pref.getString('uid');
    print(map);

    HttpHelper.post(HttpHelper.API_BusinessInfo, (data) async {
      //loadpage.close();
      if (data != null) {
        print(data);
        //Toast.show(data["msg"], context);

        if (data["code"].toString() == "1") {
          if (data["info"]["avatar"].length != 0) {
            setState(() {
              // avatar = data["info"]["avatar"];
            });
          }
          var info = data["info"];
          setState(() {
            status = info["status"].toString();
          });
        }
      }
    }, params: map);
  }

  @override
  void initState() {
    super.initState();
    // _tabs.add(Choice(title: '待处理', position: 0));
    _tabs.add(Choice(title: '进行中', position: 1));
    // _tabs.add(Choice(title: '待评价', position: 2));
    _tabs.add(Choice(title: '已完成', position: 3));
    mTabController = new TabController(vsync: this, length: _tabs.length);
    //判断TabBar是否切换
    mTabController.addListener(() {
      if (mTabController.index == mCurrentPosition) return;
      print('滑动监听' + mTabController.index.toString());
      setState(() {
        keyword="";
        keywordcontroller.text = "";
        page = 1;
        mCurrentPosition = mTabController.index;
        if (mTabController.index == 0)
          type = 1;
        else
          type = 3;
        //type = mTabController.index;
      });
      loaddata(); //滑动时加载数据
    });
    scrollController.addListener(() {
      if (scrollController.position.pixels ==
          scrollController.position.maxScrollExtent) {
        if (hasmore) {
          page = page + 1;
          loaddata();
        }
        // loadMore();
      }
    });
    // loaduserinfo();
    loaddata();
  }

  //加载数据
  loaddata() async {
    // Toast.show('数据正在加载中...',context);
    Map<String, String> map = new Map();
    SharedPreferences pref = await SharedPreferences.getInstance();
    map["id"] = pref.getString('uid');
    map["type"] = type.toString();
    map["page"] = page.toString();
    map["keyword"] = keyword;
    print(map);
    EasyLoading.show(status:"加载中...");

    HttpHelper.post(HttpHelper.API_BussinessOrderList, (data) async {
      EasyLoading.dismiss();
      if (data != null) {
        print(data);
        if (data["code"].toString() == "1") {
          Future.delayed(Duration(seconds: 1), () {
            //loadpage.close();
            if (data["info"].length < 10) {
              setState(() {
                hasmore = false;
              });
            } else {
              setState(() {
                hasmore = true;
              });
            }
            if (page == 1) {
              orders = [];
            }
            orders.addAll(data["info"]);
            setState(() {
              orders = orders;
            });
          });
          // setState(() {
          //   orders = data["info"];
          // });
          //pref.setStringList('userinfo', data["info"]);

        }
      }
    }, params: map);
  }

  @override
  void dispose() {
    super.dispose();
    mTabController.dispose();
  }

  Widget buildcontent() {
    List<Widget> tiles = [];
    Widget content;
    if (orders.length == 0) {
      tiles.add(Center(
          child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
            Padding(
                padding: new EdgeInsets.fromLTRB(
                    15, MediaQuery.of(context).size.height / 2 - 100, 15, 0),
                child: new Text('暂无订单数据'))
          ])));
    } else {
      for (var i = 0; i < orders.length; i++) {
        var order = orders[i];
        tiles.add(Padding(
            padding: new EdgeInsets.fromLTRB(15, 10, 15, 0),
            child: Container(
              decoration: new BoxDecoration(
                color: Colors.white,
              ),
              child: Column(
                children: <Widget>[
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 10, 20, 10),
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 2,
                            child: new Text(
                              order["order_sn"],
                              style: TextStyle(
                                  color: Color.fromRGBO(51, 51, 51, 1),
                                  fontSize: 13),
                            )),
                        Expanded(
                          flex: 1,
                          child: new Align(
                              alignment: Alignment.centerRight,
                              child: Container(
                                  padding: new EdgeInsets.fromLTRB(5, 2, 5, 2),
                                  color: Color.fromRGBO(255, 204, 48, 0.3),
                                  child: new Text(
                                    order["test_type"],
                                    style: TextStyle(
                                        color: Color.fromRGBO(255, 204, 48, 1),
                                        fontSize: 12),
                                  ))),
                        )
                      ],
                    ),
                  ),
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 10, 20, 10),
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 1,
                            child: new Text(
                              '联系电话',
                              style: TextStyle(
                                  fontSize: 12,
                                  color: Color.fromRGBO(51, 51, 51, 1)),
                            )),
                        Expanded(
                          flex: 1,
                          child: new Align(
                              alignment: Alignment.centerRight,
                              child: Container(
                                  child: new Text(
                                order["contact_mobile"],
                                style: TextStyle(
                                    color: Color.fromRGBO(153, 153, 153, 1),
                                    fontSize: 12),
                              ))),
                        )
                      ],
                    ),
                  ),
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
                    child: Row(
                      children: <Widget>[
                        // Expanded(
                        //     flex: 1,
                        //     child:
                        new Text(
                          '检测时间',
                          style: TextStyle(
                              fontSize: 12,
                              color: Color.fromRGBO(51, 51, 51, 1)),
                        ),
                        //),
                        Expanded(
                          child: new Align(
                              alignment: Alignment.centerRight,
                              child: Container(
                                  child: new Text(
                                order["add_time"],
                                style: TextStyle(
                                    color: Color.fromRGBO(153, 153, 153, 1),
                                    fontSize: 12),
                              ))),
                        )
                      ],
                    ),
                  ),
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 1,
                            child: new Text(
                              '车源价格',
                              style: TextStyle(
                                  fontSize: 12,
                                  color: Color.fromRGBO(51, 51, 51, 1)),
                            )),
                        Expanded(
                          flex: 1,
                          child: new Align(
                              alignment: Alignment.centerRight,
                              child: Container(
                                  child: new Text(
                                "¥" + order["car_price"] + "万",
                                style: TextStyle(
                                    color: Color.fromRGBO(251, 73, 57, 1),
                                    fontSize: 12),
                              ))),
                        )
                      ],
                    ),
                  ),
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 1,
                            child: new Text(
                              '汽车品牌',
                              style: TextStyle(
                                  fontSize: 12,
                                  color: Color.fromRGBO(51, 51, 51, 1)),
                            )),
                        Expanded(
                          flex: 1,
                          child: new Align(
                              alignment: Alignment.centerRight,
                              child: Container(
                                  child: new Text(
                                order["brand_string"]["name"],
                                style: TextStyle(
                                    color: Color.fromRGBO(153, 153, 153, 1),
                                    fontSize: 12),
                              ))),
                        )
                      ],
                    ),
                  ),
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 1,
                            child: new Text(
                              '车型',
                              style: TextStyle(
                                  fontSize: 12,
                                  color: Color.fromRGBO(51, 51, 51, 1)),
                            )),
                        Expanded(
                          flex: 1,
                          child: new Align(
                              alignment: Alignment.centerRight,
                              child: Container(
                                  child: new Text(
                                order["cartype_string"]["name"],
                                // order["cartype_string"]["name"]+order['type_list_name']!=null?order['type_list_name']:'',
                                style: TextStyle(
                                    color: Color.fromRGBO(153, 153, 153, 1),
                                    fontSize: 12),
                              ))),
                        )
                      ],
                    ),
                  ),
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 1,
                            child: new Text(
                              '车身图片',
                              style: TextStyle(
                                  fontSize: 12,
                                  color: Color.fromRGBO(51, 51, 51, 1)),
                            )),
                        Expanded(
                            flex: 1,
                            child: new Align(
                                alignment: Alignment.centerRight,
                                child: Container(
                                  child: order['thumb'] == ""
                                      ? Text(
                                          "无",
                                          style: TextStyle(
                                              color: Color.fromRGBO(
                                                  153, 153, 153, 1),
                                              fontSize: 12),
                                        )
                                      : CachedNetworkImage(
                                          imageUrl: order['thumb'],
                                          width: 80,
                                          height: 80,
                                          fit: BoxFit.cover),
                                  //     new Text(
                                  //  order['plate_no'],
                                  //   style: TextStyle(
                                  //       color: Color.fromRGBO(153, 153, 153, 1),
                                  //       fontSize: 12),
                                ))),
                      ],
                    ),
                  ),
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 1,
                            child: new Text(
                              '车牌',
                              style: TextStyle(
                                  fontSize: 12,
                                  color: Color.fromRGBO(51, 51, 51, 1)),
                            )),
                        Expanded(
                          flex: 1,
                          child: new Align(
                              alignment: Alignment.centerRight,
                              child: Container(
                                  child: new Text(
                                order['car_num'],
                                style: TextStyle(
                                    color: Color.fromRGBO(153, 153, 153, 1),
                                    fontSize: 12),
                              ))),
                        )
                      ],
                    ),
                  ),
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 1,
                            child: new Text(
                              '车架号',
                              style: TextStyle(
                                  fontSize: 12,
                                  color: Color.fromRGBO(51, 51, 51, 1)),
                            )),
                        Expanded(
                          flex: 1,
                          child: new Align(
                              alignment: Alignment.centerRight,
                              child: Container(
                                  child: new Text(
                                order['chejia_num'],
                                style: TextStyle(
                                    color: Color.fromRGBO(153, 153, 153, 1),
                                    fontSize: 12),
                              ))),
                        )
                      ],
                    ),
                  ),
                  Padding(
                      padding: new EdgeInsets.fromLTRB(20, 10, 20, 10),
                      child: Align(
                          alignment: Alignment.centerLeft,
                          //alignment: Alignment.centerRight,
                          child: new Container(
                              child: new Row(
                                  mainAxisAlignment: MainAxisAlignment.end,
                                  crossAxisAlignment: CrossAxisAlignment.end,
                                  children: <Widget>[
                                new Material(
                                  //INK可以实现装饰容器
                                  child: new Ink(
                                    //用ink圆角矩形
                                    // color: Colors.red,
                                    decoration: new BoxDecoration(
                                      //背景
                                      color: Colors.white,
                                      //设置四周圆角 角度
                                      borderRadius: BorderRadius.all(
                                          Radius.circular(15.0)),
                                      //设置四周边框
                                      border: new Border.all(
                                          width: 1,
                                          color:
                                              Color.fromRGBO(255, 204, 48, 1)),
                                    ),
                                    child: new InkWell(
                                        //圆角设置,给水波纹也设置同样的圆角
                                        //如果这里不设置就会出现矩形的水波纹效果
                                        borderRadius:
                                            new BorderRadius.circular(15.0),
                                        //设置点击事件回调
                                        onTap: () {
                                          print(order["id"].toString());
                                          if (order["status"].toString() !=
                                              "3") {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (_) {
                                              return new BussinessPapularinspects(
                                                  order["id"].toString(),
                                                  2, {});
                                            }));
                                            //   Navigator.of(context).push(
                                            //     new MaterialPageRoute(builder: (_) {
                                            //   return new Papularinspects(
                                            //       order["id"].toString(), 2,{});
                                            // }));
                                          } else {
                                            //打印或修改报告
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (_) {
                                              return new BussinessEditResult(
                                                  order["id"].toString(),
                                                  2, {});
                                            }));
                                            // Navigator.of(context).push(
                                            //     new MaterialPageRoute(
                                            //         builder: (_) {
                                            //   return new PapularinspectReults(
                                            //       order["id"].toString(), 2);
                                            // }));
                                          }
                                        },
                                        child: Container(
                                          //设置 child 居中
                                          alignment: Alignment(0, 0),
                                          height: 30,
                                          width: 125,
                                          child: Text(
                                            order["status"].toString() != "3"
                                                ? "继续检测"
                                                : "打印或修改报告",
                                            style: TextStyle(
                                                color: Color.fromRGBO(
                                                    255, 204, 48, 1)),
                                          ),
                                        )),
                                  ),
                                ),

                                // order["status"].toString() == "3"&&order["canedit"].toString()=="1"?
                                // Padding(padding: new EdgeInsets.fromLTRB(10, 0, 0, 0),child:
                                // new Material(
                                //   //INK可以实现装饰容器
                                //   child: new Ink(
                                //     //用ink圆角矩形
                                //     // color: Colors.red,
                                //     decoration: new BoxDecoration(
                                //       //背景
                                //       color: Colors.white,
                                //       //设置四周圆角 角度
                                //       borderRadius:
                                //           BorderRadius.all(Radius.circular(15.0)),
                                //       //设置四周边框
                                //       border: new Border.all(
                                //           width: 1,
                                //           color: Color.fromRGBO(255, 204, 48, 1)),
                                //     ),
                                //     child: new InkWell(
                                //         //圆角设置,给水波纹也设置同样的圆角
                                //         //如果这里不设置就会出现矩形的水波纹效果
                                //         borderRadius: new BorderRadius.circular(15.0),
                                //         //设置点击事件回调
                                //         onTap: () {
                                //           print(order["id"].toString());

                                //             Navigator.of(context).push(
                                //               new MaterialPageRoute(builder: (_) {
                                //             return new EditResult(
                                //                 order["id"].toString(), 2,{});
                                //           }));

                                //         },
                                //         child: Container(
                                //           //设置 child 居中
                                //           alignment: Alignment(0, 0),
                                //           height: 30,
                                //           width: 85,
                                //           child: Text(
                                //            "编辑结果",
                                //             style: TextStyle(
                                //                 color:
                                //                     Color.fromRGBO(255, 204, 48, 1)),
                                //           ),
                                //         )),
                                //   ),
                                // )):new Container(height:0),

                                order["status"].toString() == "3" &&
                                        order["is_subguratee"].toString() == "0"
                                    ? Padding(
                                        padding: new EdgeInsets.fromLTRB(
                                            10, 0, 0, 0),
                                        child: Align(
                                            alignment: Alignment.centerRight,
                                            child: new Container(
                                              child: new Material(
                                                //INK可以实现装饰容器
                                                child: new Ink(
                                                  //用ink圆角矩形
                                                  // color: Colors.red,
                                                  decoration: new BoxDecoration(
                                                    //背景
                                                    color: Colors.white,
                                                    //设置四周圆角 角度
                                                    borderRadius:
                                                        BorderRadius.all(
                                                            Radius.circular(
                                                                15.0)),
                                                    //设置四周边框
                                                    border: new Border.all(
                                                        width: 1,
                                                        color: Color.fromRGBO(
                                                            255, 204, 48, 1)),
                                                  ),
                                                  child: new InkWell(
                                                      //圆角设置,给水波纹也设置同样的圆角
                                                      //如果这里不设置就会出现矩形的水波纹效果
                                                      borderRadius:
                                                          new BorderRadius
                                                              .circular(15.0),
                                                      //设置点击事件回调
                                                      onTap: () {
                                                        print(order["id"]
                                                            .toString());

                                                        Navigator.of(context).push(
                                                            new MaterialPageRoute(
                                                                builder: (_) {
                                                          return new GuaranteePage(
                                                              order["id"]
                                                                  .toString(),
                                                              1);
                                                        }));
                                                      },
                                                      child: Container(
                                                        //设置 child 居中
                                                        alignment:
                                                            Alignment(0, 0),
                                                        height: 30,
                                                        width: 85,
                                                        child: Text(
                                                          "保修",
                                                          style: TextStyle(
                                                              color: Color
                                                                  .fromRGBO(
                                                                      255,
                                                                      204,
                                                                      48,
                                                                      1)),
                                                        ),
                                                      )),
                                                ),
                                              ),
                                            )
                                            // child: new RaisedButton(
                                            //   child: Text('申请补考'),
                                            //   onPressed: () {},
                                            // ),
                                            ),
                                      )
                                    : new Text(''),
                              ])))),
                ],
              ),
            )));
      }
    }
    content = new Column(
        children: tiles //重点在这里，因为用编辑器写Column生成的children后面会跟一个<Widget>[]，
        //此时如果我们直接把生成的tiles放在<Widget>[]中是会报一个类型不匹配的错误，把<Widget>[]删了就可以了
        );
    return content;
  }
}

Widget buttons() {
  Widget button = Container(
    margin: EdgeInsets.only(left: 40, top: 40),
    child: new Material(
      //INK可以实现装饰容器
      child: new Ink(
        //用ink圆角矩形
        // color: Colors.red,
        decoration: new BoxDecoration(
          //背景
          color: Colors.white,
          //设置四周圆角 角度
          borderRadius: BorderRadius.all(Radius.circular(25.0)),
          //设置四周边框
          border: new Border.all(width: 1, color: Colors.red),
        ),
        child: new InkWell(
            //圆角设置,给水波纹也设置同样的圆角
            //如果这里不设置就会出现矩形的水波纹效果
            borderRadius: new BorderRadius.circular(25.0),
            //设置点击事件回调
            onTap: () {},
            child: Container(
              //设置 child 居中
              alignment: Alignment(0, 0),
              height: 50,
              width: 300,
              child: Text("点击 Container 圆角边框"),
            )),
      ),
    ),
  );
  return button;
}

class Choice {
  const Choice({this.title, this.icon, this.position});
  final String title;
  final int position;
  final IconData icon;
}
